Skip to content

Add safer intents sample #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Add safer intents sample #162

wants to merge 7 commits into from

Conversation

yrezgui
Copy link
Contributor

@yrezgui yrezgui commented May 1, 2024

No description provided.

@yrezgui yrezgui marked this pull request as ready for review May 22, 2024 15:10
Copy link
Contributor Author

@yrezgui yrezgui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sabs231 You should add more inline comments to explain the code

@@ -34,7 +34,7 @@ android {

defaultConfig {
applicationId = "com.example.platform.app"
minSdk = 21
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not looking to upgrade our minSdk to 24. You should use RequiresApi annotation around your sample instead

}
@Composable
fun HelloAndroidScreen() {
Text(text = "Hello Android!")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline this function directly inside the Surface composable

<activity android:name=".SaferIntentsActivity"
android:exported="true">
<intent-filter>
<action android:name="com.example.platform.security.intents.MY_ACTION" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this intent action filter, will this activity be launched with the NULL intent? If yes, explain it in comments

sabs231 added 5 commits May 23, 2024 11:19
Update the timeout to check if the test can be run
Update some github action version to latest (older are being deprecated)

Update min api level to 27
Changing emulator host because x86_64 does not run on arm64
Update api level to 31
Move the base api level to 31
@yrezgui
Copy link
Contributor Author

yrezgui commented Mar 18, 2025

/gemini summary

Copy link

Summary of Changes

This pull request adds a new sample, SaferIntents, to demonstrate the importance of handling intents correctly to avoid potential crashes. The sample includes two buttons: one that sends a NULL intent (which is now handled with exception handling to prevent crashes) and another that sends a regular intent. The PR also updates the Gradle configuration, including upgrading the Android Gradle Plugin (AGP) and Gradle version, and adjusts the minimum SDK version for the app.

Highlights

  • New Sample: SaferIntents: Introduces a new sample demonstrating how to handle intents safely to prevent ActivityNotFoundException crashes when a NULL intent is sent.
  • Gradle Updates: Updates the Gradle version to 8.6 and the Android Gradle Plugin (AGP) to 8.4.1. Also, the minimum SDK version is increased to 24.
  • Workflow Updates: Updates the GitHub Actions workflow to use actions/checkout@v4 and actions/upload-artifact@v4 and targets API levels 31 and 34 for testing.

Changelog

Click here to see the changelog
  • .github/workflows/build.yml
    • Updates actions/checkout to v4 (line 19).
    • Updates actions/upload-artifact to v4 (lines 49, 56, and 97).
    • Changes runs-on to macos-latest-large (line 63).
    • Updates the API levels tested to 31 and 34 (line 67).
  • app/build.gradle.kts
    • Increases minSdk to 24 (line 37).
  • gradle/libs.versions.toml
    • Updates agp to version 8.4.1 (line 21).
    • Updates Gradle version to 8.6 (line 20).
  • gradle/wrapper/gradle-wrapper.properties
    • Updates distributionUrl to Gradle 8.6 (line 20).
  • samples/README.md
    • Adds a link to the new SaferIntents sample (line 93).
  • samples/security/intents/README.md
    • Creates a README file for the SaferIntents sample, explaining its purpose and functionality.
  • samples/security/intents/build.gradle.kts
    • Creates a build.gradle.kts file for the SaferIntents sample, including the plugin and namespace.
  • samples/security/intents/src/main/AndroidManifest.xml
    • Creates an AndroidManifest.xml file for the SaferIntents sample, declaring the SaferIntentsActivity and intent filter.
  • samples/security/intents/src/main/java/com/example/platform/security/intents/SaferIntents.kt
    • Creates the SaferIntents composable function, which includes buttons to send a NULL intent (with exception handling) and a regular intent.
  • samples/security/intents/src/main/java/com/example/platform/security/intents/SaferIntentsActivity.kt
    • Creates the SaferIntentsActivity, which displays a simple "Hello Android!" screen.

Activity

  • yrezgui requested a summary of the pull request using the command /gemini summary.
  • yrezgui suggested using RequiresApi annotation instead of upgrading the minSdk version.
  • yrezgui suggested inlining the HelloAndroidScreen function directly inside the Surface composable.
  • yrezgui asked for clarification on whether the activity can be launched with a NULL intent without the intent action filter, and if so, to explain it in the comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants